#{extends '/include/main_include.html'/}

<script type="text/javascript">
//<!--
/*********************
 * Document Ready
 * 2012.05.02 : 신규작성 (박상헌)
 *********************/
$(document).ready(function(){
	/**********************
	 * 로그인
	 * 2012.05.02 : 신규작성 (박상헌)
	 **********************/
	$("#user_login").click(function(){
		// TODO
		var user_email = $("#user_email").val();
		var user_password = $("#user_password").val();
		console.log("Email : " + user_email);
		console.log("Password : " + user_password);
		var request_data = {
				user_email : user_email,
				user_password : user_password
		}; // request_data
		
		$.ajax({
			type 	: 'POST',
			async 	: true,
			url 	: '/web/login',
			data	: $.param(request_data),
			success : function(res){
				var code = res['CODE'];
				var message = res['MESSAGE'];
				console.log("CODE : " + code);
				console.log("MESSAGE : " + message);
				if (code == '0000'){
					alert("성공");
					// Move to MyPage
					location.href="";
				} else {
					// TODO : Move to Error Page
					location.href="";
				} // if
			}, // success()
			error	: function(data, status, err){
				alert(error);
			} // error()
		});
	}); // 로그인
	
	/***********************
	 * 회원가입
	 * 2012.05.02 : 신규작성 (박상헌)
	 ***********************/
	$("#signup_submit").click(function(){
		var signup_form = $("#signup_form");
		
		var user_email = $("#signup_email").val();
		var user_firstname = $("#signup_firstname").val();
		var user_lastname = $("#signup_lastname").val();
		var user_password = $("#signup_password").val();
		
		if (user_email == '') {
			alert("이메일을 입력하세요");
			return;
		} // if
		
		var email_valid_result = valid.email(user_email);
		if (!email_valid_result) {
			alert("올바른 이메일을 입력하세요");
			return;
		} // if
		
		if (user_firstname == '') {
			alert("성을 입력하세요.");
			return;
		} // if
		
		if (user_lastname == '') {
			alert("이름을 입력하세요.");
			return;
		} // if
		
		if (user_password == '') {
			alert("비밀번호를 입력하세요.");
			return;
		} // if
		
		signup_form.submit();
	}); // Sign Up
}); // document ready
//-->
</script>

<div class="index index-head">
	<h1>LetzMeet</h1>
	<label>
		<span class="placeholder">이메일</span>
		<input type="text" class="index head input" id="user_email"/>
	</label>
	<label>
		<span class="placeholder">비밀번호</span>
		<input type="password" class="index head input" id="user_password"/>
	</label>
	<label>
		<input type="button" class="index head button" id="user_login" value="Sign In"/>
	</label>
</div>

<div class="index index-body">
	<div class="index index-body index-image">
		<img src=""/>
	</div>
	<div class="index index-body index-form">
		<h1>Sign Up</h1>
		<form action="/web/signup" method="POST" id="signup_form">
			<label>
				<span>Email</span>
				<input type="text" class="index input" id="signup_email" name="signup_email"/>
			</label>
			<label>
				<span>First Name</span>
				<input type="text" class="index input" id="signup_firstname" name="signup_firstname"/>
			</label>
			<label>
				<span>Last Name</span>
				<input type="text" class="index input" id="signup_lastname" name="signup_lastname"/>
			</label>
			<label>
				<span>Password</span>
				<input type="password" class="index input" id="signup_password" name="signup_password"/>
			</label>
			<input type="button" class="index button" id="signup_submit" value="Sign Up"/>
		</form>
	</div>
</div>
